/**
 * Created by Joe on 2017/7/5 0005.
 */

var Goods = {
    create: {
        form: "#createNew-form",
        modal: "#basis-new-modal",
        datatable: '#DataTables_params',
        query_form: "#query-form",
        validator: ""
    },
    detail: {
        form: "#goods-detail-form",
        modal: "#basis-params-modal",
        validator: ""
    },
    type: {
        create: 0,
        update: 1,
        readonly: 2
    },
    fields: {
        selects: ["type"], //下拉框
        radios: [],//单选框
        checkboxs: [],//复选款
        textareas: [],//多行文本框
        selfDefine: [{"field": "metroLine ", "selector": "a.metro_line"}]
    },
    submit: 0,
    default_option: {
        type: "01"
    },
    detailSteps:null,
    newSteps:null,
    repairSwitchchery: null,
    recoverSwitchchery: null,
    targetSwitchChery: null
};

$(document).ready(function () {
    /** 初始化表单 */
    initFormValidate();
    /** 初始化表单 */
    initDataTable();
    /**init steps forms*/
    initSteps();
    /**init icheck plugin */
    initIcheck();
    /** init color box*/
    Images.initColorbox();
    /** init baidu uploader*/
    Uploader.initUploader(Uploader.server.goods_images);
    /** query by  goodsname and part  */
    $('#btn-query').on('click', function () {
        $("#DataTables_goods_list").DataTable().rows().remove().draw();
        var url = /*[[@{/queryGoodsBy}]]*/ 'queryGoodsBy';
        var param = $("#query-goods-form").serialize();
        Utils.ajaxSubmit(url, param, function (data) {
            if (data.result == "success") {
                addTableRow(data.content, "#DataTables_goods_list");
            }
        })
    });
    $('#btn-query-readonly').on('click', function () {
        $("#DataTables_readonly").DataTable().rows().remove().draw();
        var url = /*[[@{/queryGoodsBy}]]*/ 'queryGoodsBy';
        var param = $("#query-goods-form").serialize();
        Utils.ajaxSubmit(url, param, function (data) {
            if (data.result == "success") {
                addTableRowRead(data.content, "#DataTables_readonly");
            }
        })
    });
    /** delete by id **/
    $('#DataTables_goods_list').on('click', '.btn-detail-delete', function () {
        //delete tr row
        var $tr = $(this).parents('tr');
        var url = /*[[@{/deleteGoods}]]*/ 'deleteGoods';
        Utils.ajaxSubmit(url + "/" + $(this).siblings("input").val(), {}, function (data) {
            if (data.result == "success") {
                var row = $('#DataTables_goods_list').DataTable().row($tr);
                row.remove().draw();
                layer.msg('备件删除成功', {time: 3000, icon: 6});
            }
            if (data.result == "fail") {
                Utils.errorAlert(data.result.errorMessage);
            }
        });
    });
    /** create new goods **/
    $('#btn-createNew').on('click', function () {
        $("#real_img_new").empty();
        Images.setImagesParentTarget("#real_img_new");//设置图片上传成功显示容器
        Images.setFormParentTarget("#createNew-form");
        Utils.clearForm("#createNew-form");
        Goods.submit = Goods.type.create;
        $('#createNew-form .supportService').iCheck('check');
        $('#createNew-form .supportRecover').iCheck('check');
        for (var i=0;i<3;i++)
        {
            var currentIndex = $("#createNew-form").steps("getCurrentIndex");
            if(currentIndex==0)break;
            $("#createNew-form").steps("previous");
        }
        $("#createNew-modal").modal("toggle");
    });
    /** get the detail info of goods  **/
    $('#DataTables_goods_list').on('click', ".btn-detail", function () {
        Goods.submit = Goods.type.update;
        requestDetail($(this).siblings("input").val());
    });
    $('#DataTables_readonly').on('click', ".btn-detail", function () {
        Goods.submit = Goods.type.readonly;
        requestDetail($(this).siblings("input").val());
    });
    /** set as  cover image */
    $("#createNew-form").on('click', ".setCover", function () {
        var targetEle = $(this);
        var imgId = $(this).attr("data-id");
        Images.setCoverAjaxSubmit(imgId, targetEle);
    });
    /** set as cover image*/
    $("#goods-detail-form").on('click', ".setCover", function () {
        var targetEle = $(this);
        var imgId = $(this).attr("data-id");
        Images.setCoverAjaxSubmit(imgId, targetEle);
    });
    /** remove image */
    $("#createNew-form").on('click', '.remove-img', function () {
        var targetEle = $(this);
        var imgId = $(this).attr("data-id");
        Images.removeAjaxSubmit(imgId, targetEle);
    });
    /** remove image */
    $("#goods-detail-form").on('click', '.remove-img', function () {
        var targetEle = $(this);
        var imgId = $(this).attr("data-id");
        Images.removeAjaxSubmit(imgId, targetEle);
    });
    /** when the type changes  change the content of private params*/
    changePrivateParams(Goods.default_option.type);
    $("body").on("change", '#goods-type', function () {
        changePrivateParams($(this).val());
    });
    $('#createNew-form').on('click', '.uploader', function (e) {
        $('#filePicker input[name=file]').click();
        Uploader.target_alert = "createNew-form";
    });
    $('#goods-detail-form').on('click', '.uploader', function (e) {
        $('#filePicker input[name=file]').click();
        Uploader.target_alert = "goods-detail-form";
    });
});
function requestCreateNew() {
    var task = $.Deferred();
    var url = /*[[@{/createGoods}]]*/ 'createGoods';
    var param = $("#createNew-form").serialize();
    Utils.ajaxSubmit(url, param).done(function (data) {
        if (data.result == "success") {
            $("#createNew-form").find(".goodsId").val(data.content.id);
            $("#current_goodsId").val(data.content.id);
            addTableSingleRow(data.content, "#DataTables_goods_list");
            task.resolve(true);
        }
        if (data.result == "fail") {
            Utils.errorAlert(data.errorMessage);
            task.resolve(false);
        }
    });
    return task;
}
function requestUpdate(targetForm,isCloseModal) {
    var task = $.Deferred();
    var url = /*[[@{/updateGoods}]]*/ 'updateGoods';
    var param = $(targetForm).serialize();
    Utils.ajaxSubmit(url, param).done(function (data) {
        if (data.result == "success") {
            Images.uploadedImgCacheArr.splice(0, Images.uploadedImgCacheArr.length);
            if (Goods.submit == Goods.type.update) {
                $("#goods-detail-modal").modal("toggle");
            }
            Utils.console_log("isCloseModal",isCloseModal);
            if ((Goods.submit == Goods.type.create) && isCloseModal) {
                $("#createNew-modal").modal("toggle");
            }
            task.resolve(true);
        }
        if (data.result == "fail") {
            Utils.errorAlert(data.errorMessage);
            task.resolve(false);
        }
    });
    return task;
}
function requestDetail(goodsId) {
    var url = /*[[@{/queryGoodsByKey}]]*/ 'queryGoodsByKey';
    Utils.clearForm("#goods-detail-form");
    $("#real_img").empty();
    Utils.ajaxSubmit(url + "/" + goodsId, {}, function (data) {
        // console.log("data ： ", data);
        if (data.result == "success") {
            changePrivateParams(data.content.type);
            Utils.fillForms(data.content, Goods.fields);
            $("#current_goodsId").val(data.content.id);
            setChecked(data.content.isSupportService, '#goods-detail-form .supportService');
            setChecked(data.content.isSupportRecover, '#goods-detail-form .supportRecover');
            Images.iteratorImagelist(data.content.goodsImages, "#real_img");
            Images.setImagesParentTarget("#real_img");//设置图片上传成功显示容器
            Images.setFormParentTarget("#goods-detail-form");
            for (var i=0;i<3;i++)
            {
                var currentIndex = $("#goods-detail-form").steps("getCurrentIndex");
                if(currentIndex==0)break;
                $("#goods-detail-form").steps("previous");
            }
            $("#goods-detail-modal").modal("toggle");
        }
        if (data.result == "fail") {
            Utils.errorAlert(data.errorMessage);
        }
    });
}
/**添加table行*/
function addTableRow(goodsList, targetEle) {
    $.each(goodsList, function (k, v) {
        addTableSingleRow(v, targetEle);
    });
}

function addTableSingleRow(v, targetEle) {
    var btnRemoveEle = '<input type="hidden" value="' + v.id + '"> <a class="btn btn-primary btn-detail" >查看明细</a>';
    btnRemoveEle = btnRemoveEle.concat('&nbsp;&nbsp;&nbsp;<a class="btn btn-danger btn-detail-delete">删除</a>');
    $(targetEle).dataTable().fnAddData([v.goodsName, v.typeDesc, v.title, v.status, v.price, v.part, v.substitutePart, btnRemoveEle]);
}

/**添加table行*/
function addTableRowRead(goodsList, targetEle) {
    $.each(goodsList, function (k, v) {
        var btnRemoveEle = '<input type="hidden" value="' + v.id + '"> <a class="btn btn-primary btn-detail" >查看明细</a>';
        $(targetEle).dataTable().fnAddData([v.goodsName, v.typeDesc, v.title, v.status, v.price, v.part, v.substitutePart, btnRemoveEle]);
    });
}
/**
 * single params  each row
 * */
function buildSingleParams(param) {
    var tmpl = '  <div class="form-group"> ' +
        '<label class="col-sm-2 control-label">' + param.label + '：</label> ' +
        '<div class="col-sm-4"> <input type="text" placeholder="请输入' + param.label + '" name="' + param.name + '" class="form-control"> </div> ' +
        '</div>'
    return tmpl;
}
/**
 * double params each row
 *
 * */
function buildDoubleParams(param, param2) {
    var tmpl = '  <div class="form-group"> ' +
        '<label class="col-sm-2 control-label">' + param.label + '：</label> ' +
        '<div class="col-sm-4"> <input type="text" placeholder="请输入' + param.label + '" name="' + param.name + '" class="form-control"> </div> ' +
        '<label class="col-sm-2 control-label">' + param2.label + '：</label> ' +
        '<div class="col-sm-4"> <input type="text" placeholder="请输入' + param2.label + '" name="' + param2.name + '" class="form-control"> </div> ' +
        '</div>'
    return tmpl;
}
/**
 *
 * init plugin form steps
 *
 * */
function initSteps() {
    var form = $("#goods-detail-form").show();
    Goods.detailSteps = initStepsForm(form);
    var form = $("#createNew-form").show();
    Goods.newSteps = initStepsForm(form);

}
function initIcheck(){
    $('input.support').iCheck({
        checkboxClass: 'icheckbox_square-green',
        radioClass: 'iradio_square-green',
        increaseArea: '20%'
    });
    // change input's state to 'checked'
    $('.supportService').on('ifChecked', function(event){
        $("input[name='isSupportService']").val("1");
        $("input[name='repairPriceMin']").removeAttr("readonly");
        $("input[name='repairPriceMax']").removeAttr("readonly");

    });
    $('.supportService').on('ifUnchecked', function(event){
        $("input[name='isSupportService']").val("0");
        $("input[name='repairPriceMin']").val("0");
        $("input[name='repairPriceMax']").val("0");
        $("input[name='repairPriceMin']").attr("readonly",true);
        $("input[name='repairPriceMax']").attr("readonly",true);

    });
    $('.supportRecover').on('ifChecked', function(event){
        $("input[name='isSupportRecover']").val("1");
        $("input[name='recoverPriceMin']").removeAttr("readonly");
        $("input[name='recoverPriceMax']").removeAttr("readonly");
    });
    $('.supportRecover').on('ifUnchecked', function(event){
        $("input[name='isSupportRecover']").val("0");
        $("input[name='recoverPriceMin']").val("0");
        $("input[name='recoverPriceMax']").val("0");
        $("input[name='recoverPriceMin']").attr("readonly",true);
        $("input[name='recoverPriceMax']").attr("readonly",true);
    });
}
function setChecked(isChecked, selector){
    if (isChecked == '1') {
        $(selector).iCheck('check');
    } else {
        $(selector).iCheck('uncheck');
    }
}
function initDataTable() {
    $('#DataTables_goods_list').DataTable({
        "paging": true,
        "searching": true,
        "info": true,
        "ordering": true,
        "autoWidth": false,
        "language": {
            "url": "../vendor/datatables/zh-cn.json"
        }
    });
    $('#DataTables_readonly').DataTable({
        "paging": true,
        "searching": true,
        "info": true,
        "ordering": true,
        "autoWidth": false,
        "language": {
            "url": "../vendor/datatables/zh-cn.json"
        }
    });
}

/**
 * init plugin form steps
 * @param form
 */
function initStepsForm(form) {
   return  form.steps({
        headerTag: "h3",
        bodyTag: "section",
        transitionEffect: "slideLeft",
        labels: {
            cancel: "取消",
            current: "当前步骤:",
            pagination: "页码",
            finish: "完成",
            next: "下一步",
            previous: "上一步",
            loading: "载入中 ..."
        },
        onStepChanging: function (event, currentIndex, newIndex) {
            // console.log("onStepChanging  currentIndex", currentIndex);

            // Allways allow previous action even if the current form is not valid!
            if (currentIndex > newIndex) {
                return true;
            }
            // Forbid next action on "Warning" step if the user is to young
            if (newIndex === 3 && Number($("#age-2").val()) < 18) {
                return false;
            }
            // Needed in some cases if the user went back (clean up)
            if (currentIndex < newIndex) {
                // To remove error styles
                form.find(".body:eq(" + newIndex + ") label.error").remove();
                form.find(".body:eq(" + newIndex + ") .error").removeClass("error");
            }
            form.validate().settings.ignore = ":disabled,:hidden";
            var isSuccess = false;
            if (form.valid()) {
                isSuccess = true;
                if (Goods.submit == Goods.type.create) {
                    var goodsId =  $("#createNew-form").find(".goodsId").val();
                    // console.log("goodsId", $.trim(goodsId));
                    // console.log("  $.trim(goodsId)==''", $.trim(goodsId) == '');
                    if (currentIndex == 0 && $.trim(goodsId) == '') {
                        isSuccess = requestCreateNew();
                    } else if (currentIndex == 1 || currentIndex == 2) {
                        if(currentIndex==1){
                            isSuccess = requestUpdate("#createNew-form",false);
                        }else{
                            isSuccess = requestUpdate("#createNew-form",true);
                        }

                    }
                }
            }
            // console.log("isSuccess", isSuccess);
            return isSuccess;
        },
        onStepChanged: function (event, currentIndex, priorIndex) {
            // console.log("onStepChanged currentIndex", currentIndex);
            // Used to skip the "Warning" step if the user is old enough.
            if (currentIndex === 2 && Number($("#age-2").val()) >= 18) {
                form.steps("next");
            }
            // Used to skip the "Warning" step if the user is old enough and wants to the previous step.
            if (currentIndex === 2 && priorIndex === 3) {
                form.steps("previous");
            }
        },
        onFinishing: function (event, currentIndex) {
            form.validate().settings.ignore = ":disabled";
            return form.valid();
        },
        onFinished: function (event, currentIndex) {
            // console.log("onFinished  currentIndex", currentIndex);
            if (Goods.submit == Goods.type.create) {
                if ($(Goods.create.form).valid()) {
                    if(currentIndex==1){
                        requestUpdate("#createNew-form",false);
                    }else{
                        requestUpdate("#createNew-form",true);
                    }
                } else {
                    Goods.create.validator.focusInvalid();
                }
            }
            if (Goods.submit == Goods.type.update) {
                if ($(Goods.detail.form).valid()) {
                    requestUpdate("#goods-detail-form",false);
                } else {
                    Goods.detail.validator.focusInvalid();
                }
            }
            if (Goods.submit == Goods.type.readonly) {
                $("#goods-detail-modal").modal("toggle");
            }
        }
    }).validate({
        errorPlacement: function errorPlacement(error, element) {
            element.before(error);
        },
        rules: {
            confirm: {
                equalTo: "#password-2"
            }
        }
    });

}

function initFormValidate() {
    Goods.create.validator = $(Goods.create.form).validate({
        errorElement: "span",
        errorClass: "error-block",
        focusInvalid: true,
        rules: {
            brand: {required: false, maxlength: 15},
            // title: {required: true, maxlength: 100},
            goodsName: {required: true, maxlength: 30},
            goodsDesc: {required: false, maxlength: 50},
            price: {required: true, maxlength: 15},
            part: {required: false, maxlength: 15},
            substitutePart: {required: false, maxlength: 50},
            capacity: {required: false, maxlength: 15},
            model: {required: false, maxlength: 10},
            platform: {required: false, maxlength: 15},
            power: {required: false, maxlength: 15},
            kernelNum: {required: false, maxlength: 15},
            size: {required: false, maxlength: 15},
            goodsCache: {required: false, maxlength: 15},
            frequency: {required: false, maxlength: 15},
            hardwareInterface: {required: false, maxlength: 15},
            speed: {required: false, maxlength: 15},
            repairPriceMin: {required: false, maxlength: 15},
            repairPriceMax: {required: false, maxlength: 15},
            recoverPriceMin: {required: false, maxlength: 15},
            recoverPriceMax: {required: false, maxlength: 15}
        },
        messages: {
            brand: {required: "machine必须输入", maxlength: $.validator.format("长度不能超过{0}")},
            // title: {required: "标题必须输入", maxlength: $.validator.format("长度不能超过{0}")},
            goodsName: {required: "商品名称必须输入", maxlength: $.validator.format("长度不能超过{0}")},
            goodsDesc: {maxlength: $.validator.format("长度不能超过{0}")},
            price: {required: "价格必须输入", maxlength: $.validator.format("长度不能超过{0}")},
            part: {maxlength: $.validator.format("长度不能超过{0}")},
            substitutePart: {maxlength: $.validator.format("长度不能超过{0}")},
            capacity: {maxlength: $.validator.format("长度不能超过{0}")},
            model: {maxlength: $.validator.format("长度不能超过{0}")},
            platform: {maxlength: $.validator.format("长度不能超过{0}")},
            power: {maxlength: $.validator.format("长度不能超过{0}")},
            kernelNum: {maxlength: $.validator.format("长度不能超过{0}")},
            size: {isNumber: '', maxlength: $.validator.format("长度不能超过{0}")},
            goodsCache: {isNumber: '', maxlength: $.validator.format("长度不能超过{0}")},
            frequency: {maxlength: $.validator.format("长度不能超过{0}")},
            hardwareInterface: {maxlength: $.validator.format("长度不能超过{0}")},
            speed: {maxlength: $.validator.format("长度不能超过{0}")},
            repairPriceMin: {isNumber: '', maxlength: $.validator.format("长度不能超过{0}")},
            repairPriceMax: {isNumber: '', maxlength: $.validator.format("长度不能超过{0}")},
            recoverPriceMin: {isNumber: '', maxlength: $.validator.format("长度不能超过{0}")},
            recoverPriceMax: {isNumber: '', maxlength: $.validator.format("长度不能超过{0}")}
        }
    });
    Goods.detail.validator = $(Goods.detail.form).validate({
        errorElement: "span",
        errorClass: "error-block",
        focusInvalid: true,
        rules: {
            brand: {required: false, maxlength: 15},
            // title: {required: true, maxlength: 100},
            goodsName: {required: true, maxlength: 30},
            goodsDesc: {required: false, maxlength: 50},
            price: {required: true, maxlength: 15},
            part: {required: false, maxlength: 15},
            substitutePart: {required: false, maxlength: 50},
            capacity: {required: false, maxlength: 15},
            model: {required: false, maxlength: 10},
            platform: {required: false, maxlength: 15},
            power: {required: false, maxlength: 15},
            kernelNum: {required: false, maxlength: 15},
            size: {required: false, maxlength: 15},
            goodsCache: {required: false, maxlength: 15},
            frequency: {required: false, maxlength: 15},
            hardwareInterface: {required: false, maxlength: 15},
            speed: {required: false, maxlength: 15},
            repairPriceMin: {required: false, maxlength: 15},
            repairPriceMax: {required: false, maxlength: 15},
            recoverPriceMin: {required: false, maxlength: 15},
            recoverPriceMax: {required: false, maxlength: 15}
        },
        messages: {
            brand: {required: "machine必须输入", maxlength: $.validator.format("长度不能超过{0}")},
            // title: {required: "标题必须输入", maxlength: $.validator.format("长度不能超过{0}")},
            goodsName: {required: "商品名称必须输入", maxlength: $.validator.format("长度不能超过{0}")},
            goodsDesc: {maxlength: $.validator.format("长度不能超过{0}")},
            price: {required: "价格必须输入", maxlength: $.validator.format("长度不能超过{0}")},
            part: {maxlength: $.validator.format("长度不能超过{0}")},
            substitutePart: {maxlength: $.validator.format("长度不能超过{0}")},
            capacity: {maxlength: $.validator.format("长度不能超过{0}")},
            model: {maxlength: $.validator.format("长度不能超过{0}")},
            platform: {maxlength: $.validator.format("长度不能超过{0}")},
            power: {maxlength: $.validator.format("长度不能超过{0}")},
            kernelNum: {maxlength: $.validator.format("长度不能超过{0}")},
            size: {isNumber: '', maxlength: $.validator.format("长度不能超过{0}")},
            goodsCache: {isNumber: '', maxlength: $.validator.format("长度不能超过{0}")},
            frequency: {maxlength: $.validator.format("长度不能超过{0}")},
            hardwareInterface: {maxlength: $.validator.format("长度不能超过{0}")},
            speed: {maxlength: $.validator.format("长度不能超过{0}")},
            repairPriceMin: {isNumber: '', maxlength: $.validator.format("长度不能超过{0}")},
            repairPriceMax: {isNumber: '', maxlength: $.validator.format("长度不能超过{0}")},
            recoverPriceMin: {isNumber: '', maxlength: $.validator.format("长度不能超过{0}")},
            recoverPriceMax: {isNumber: '', maxlength: $.validator.format("长度不能超过{0}")}
        }
    });
    $.validator.addMethod('isNumber', function (value, element, params) {
        return this.optional(element) || Utils.isNumber(value);
    }, "格式错误,请输入有效的数字");
}

/**
 * change the content of private params when the goods type is changed
 *  paramOne;paramTwo;paramThree;paramFour; paramFive;
 *
 * */
function changePrivateParams(value) {
    var contents = '', params = {
        "01": [{label: "容量", name: "paramOne"},{label: "尺寸", name: "paramTwo"},{label: "接口",name: "paramThree"},{label: "转速", name: "paramFour"},{label: "速率", name: "paramFive"}],
        "02": [{label: "容量", name: "paramOne"},{label: "类型", name: "paramTwo"},{label: "频率", name: "paramThree"}],
        "03": [{label: "平台", name: "paramOne"},{label: "内核数量", name: "paramTwo"},{ label: "频率",name: "paramThree"}],
        "04": [{label: "类型", name: "paramOne"},{label: "功率", name: "paramTwo"}],
        "05": [{label: "型号", name: "paramOne"},{label: "类型", name: "paramTwo"},{label: "接口类型", name: "paramThree"},{label: "速率", name: "paramFour"}],
        "06": [{label: "类型", name: "paramOne"}],
        "07": [{label: "容量", name: "paramOne"},{label: "尺寸", name: "paramTwo"},{label: "接口",name: "paramThree" },{label: "速率", name: "paramFour"}],
        "08": [{label: "型号", name: "paramOne"},{label: "类型", name: "paramTwo"},{label: "接口类型",name: "paramThree" },{label: "速率", name: "paramFour"}],
        "09": [{label: "缓存", name: "paramOne"},{label: "传输类型", name: "paramTwo"},{label: "速率", name: "paramThree"}],
        "10": [{label: "类型", name: "paramOne"},{label: "尺寸", name: "paramTwo"}],
        "11": [{label: "类型", name: "paramOne"},{label: "CPU槽位", name: "paramTwo"}],
        "12": [{label: "类型", name: "paramOne"}],
        "13": [{label: "类型", name: "paramOne"}],
        "14": [{label: "类型", name: "paramOne"}],
        "15": [{label: "类型", name: "paramOne"}],
        "16": [{label: "类型", name: "paramOne"},{label: "描述", name: "paramTwo"}],
        "17": [{label: "描述", name: "paramOne"}],
        "18": [{label: "速率", name: "paramOne"},{label: "端口数量", name: "paramTwo"},{ label: "生产厂商",name: "paramThree"}],
        "19": [{label: "速率", name: "paramOne"},{label: "端口数量", name: "paramTwo"},{ label: "生产厂商",name: "paramThree"}],
        "20": [{label: "类型", name: "paramOne"},{label: "端口数量", name: "paramTwo"},{ label: "生产厂商",name: "paramThree"}],
        "21": [{label: "速率", name: "paramOne"},{label: "端口数量", name: "paramTwo"},{ label: "生产厂商",name: "paramThree"}],
        "22": [{label: "类型", name: "paramOne"},{label: "Cache", name: "paramTwo"}, { label: "电池",name: "paramThree"}],
        "23": [{label: "生产厂商", name: "paramOne"},{label: "型号", name: "paramTwo"},{ label: "频率",name: "paramThree"}],
        "24": [{label: "生产厂商", name: "paramOne"},{label: "型号", name: "paramTwo"},{ label: "频率",name: "paramThree"}],
        "25": [{label: "描述", name: "paramOne"}],
        "26": [{label: "描述", name: "paramOne"}],
        "27": [{label: "类型", name: "paramOne"}],
        "28": [{label: "描述", name: "paramOne"}],
        "29": [{label: "类型", name: "paramOne"}],
        "30": [{label: "型号", name: "paramOne"},{label: "接口数量", name: "paramTwo"},{label: "接口速率",name: "paramThree" },{label: "激活数量", name: "paramFour"}],
        "31": [{label: "型号", name: "paramOne"}, {label: "接口数量", name: "paramTwo"}, {label: "接口速率",name: "paramThree" },{label: "激活数量", name: "paramFour"}],
        "32": [{label: "型号", name: "paramOne"},{label: "驱动器数量", name: "paramTwo"},{label: "磁带槽位", name: "paramThree"}],
        "33": [{label: "类型", name: "paramOne"}],
        "34": [{label: "类型", name: "paramOne"}],
        "35": [{label: "类型", name: "paramOne"}],
        "99": [{label: "类型", name: "paramOne"}]
    };
    var singleArr = [ "06","12", "13", "14", "15","17", "25", "26", "27","28","29","33","34","35","99" ];//该类型参数仅有1个
    var doubleArr = [ "04", "10", "11", "16"];//该类型参数仅有2个
    var threeArr = [ "02", "03", "09", "16", "18", "19", "20", "21", "22", "23", "24"];//该类型参数仅有3个
    var fourArr = [ "05", "07", "08", "30", "31"];//该类型参数仅有4个
    var fiveArr = [ "01"];//该类型参数仅有5个
    Utils.console_log("value = ",value);
    if ($.inArray(value,singleArr)!==-1) {
        // Utils.console_log("singleArr value = ",value);
        contents = contents + buildSingleParams(params[value][0]);
    }else if($.inArray(value,doubleArr)!==-1){
        // Utils.console_log("doubleArr value = ",value);
        contents = contents + buildDoubleParams(params[value][0], params[value][1]);
    } else if ($.inArray(value,threeArr)!==-1) {
        // Utils.console_log("threeArr value = ",value);
        contents = contents + buildDoubleParams(params[value][0], params[value][1]);
        contents = contents + buildSingleParams(params[value][2]);
    } else if ($.inArray(value,fourArr)!==-1) {
        // Utils.console_log("fourArr value = ",value);
        contents = contents + buildDoubleParams(params[value][0], params[value][1]);
        contents = contents + buildDoubleParams(params[value][2], params[value][3]);
    } else if ($.inArray(value,fiveArr)!==-1) {
        // Utils.console_log("fiveArr value = ",value);
        contents = contents + buildDoubleParams(params[value][0], params[value][1]);
        contents = contents + buildDoubleParams(params[value][2], params[value][3]);
        contents = contents + buildSingleParams(params[value][4]);
    }
    $(".private-params").empty();
    $(".private-params").append(contents);
}

